From: Florian Müllner Date: Thu, 14 Oct 2010 12:27:22 +0000 (+0200) Subject: iconGrid: Add alignment parameter X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~9653 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=627f1cb59a9937b984bbce47c52ca0947e51ac46;p=gnome-shell.git iconGrid: Add alignment parameter Currently the grid's content is centered, which is not appropriate for all use cases. Add an optional parameter to control the alignment. https://bugzilla.gnome.org/show_bug.cgi?id=632147 --- diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js index 05abe1bdb..3625316e8 100644 --- a/js/ui/iconGrid.js +++ b/js/ui/iconGrid.js @@ -135,9 +135,12 @@ function IconGrid(params) { IconGrid.prototype = { _init: function(params) { - params = Params.parse(params, { rowLimit: null, columnLimit: null }); + params = Params.parse(params, { rowLimit: null, + columnLimit: null, + xAlign: St.Align.MIDDLE }); this._rowLimit = params.rowLimit; this._colLimit = params.columnLimit; + this._xAlign = params.xAlign; this.actor = new St.BoxLayout({ style_class: 'icon-grid', vertical: true }); @@ -189,9 +192,19 @@ IconGrid.prototype = { let [nColumns, usedWidth] = this._computeLayout(availWidth); - let overallPaddingX = Math.floor((availWidth - usedWidth) / 2); + let leftPadding; + switch(this._xAlign) { + case St.Align.START: + leftPadding = 0; + break; + case St.Align.MIDDLE: + leftPadding = Math.floor((availWidth - usedWidth) / 2); + break; + case St.Align.END: + leftPadding = availWidth - usedWidth; + } - let x = box.x1 + overallPaddingX; + let x = box.x1 + leftPadding; let y = box.y1; let columnIndex = 0; let rowIndex = 0; @@ -231,7 +244,7 @@ IconGrid.prototype = { if (columnIndex == 0) { y += this._item_size + this._spacing; - x = box.x1 + overallPaddingX; + x = box.x1 + leftPadding; } else { x += this._item_size + this._spacing; }